//
//  SettingsTableViewCell.m
//  Wechat
//
//  Created by FONERY on 2019/9/9.
//  Copyright © 2019 Zhangfan. All rights reserved.
//

#import "SettingsTableViewCell.h"

@interface SettingsTableViewCell()
@property (weak, nonatomic) IBOutlet UILabel *titleLab;
@property (weak, nonatomic) IBOutlet UILabel *detailLab;
@property (weak, nonatomic) IBOutlet UISwitch *switchBtn;
@end

@implementation SettingsTableViewCell

+ (instancetype)cellWithTableView:(UITableView *)tableView {
    SettingsTableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:@"SettingsTableViewCellIdentifier"];
    if (cell == nil) {
        cell = [[[UINib nibWithNibName:@"SettingsTableViewCell" bundle:nil] instantiateWithOwner:nil options:nil] firstObject];
    }
    return cell;
}

+ (CGFloat)cellHeight {
    return 50;
}

- (void)awakeFromNib {
    [super awakeFromNib];
    
}

- (void)setSelected:(BOOL)selected animated:(BOOL)animated {
    [super setSelected:selected animated:animated];

    // Configure the view for the selected state
}

- (void)setSettingsModel:(SettingsModel *)settingsModel {
    _settingsModel = settingsModel;
    
    self.titleLab.text = settingsModel.title;
    self.switchBtn.hidden = YES;
    self.detailLab.hidden = YES;
    self.accessoryType = UITableViewCellAccessoryNone;
    switch (settingsModel.type) {
        case SettingsTableViewCellTypeNormal:
            self.accessoryType = UITableViewCellAccessoryDisclosureIndicator;
            break;
        case SettingsTableViewCellTypeDetail:
            self.detailLab.text = settingsModel.detail;
            self.detailLab.hidden = NO;
            break;
        case SettingsTableViewCellTypeSwitch:
            self.switchBtn.hidden = NO;
            break;
    }
    
}

@end
